package com.xingkeduo.business.operation.controller.cms;

import com.xingkeduo.business.operation.domain.CountryDomain;
import com.xingkeduo.pojo.json.CountryJson;
import com.xingkeduo.pojo.table.CountryTable;
import com.xingkeduo.util.pojo.base.BaseController;
import com.xingkeduo.util.tool.ReturnUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.xingkeduo.tool.OperaConstants.CMS_URL_PREFIX;

/**
 * 文件概述
 *
 * @author wangxilong <wangxilong@xingkeduo.com>
 * @version id:v0.1 19-2-12 下午4:32
 * @package BeautyOS
 * @copyright Copyright (c) XKD 2019
 */
@RestController
@RequestMapping(CMS_URL_PREFIX + "/ccountry")
public class CCountryController extends BaseController {
    @Autowired
    private CountryDomain countryDomain;

    //获取所有城市信息
    @RequestMapping(value = "/getAllcitys", method = RequestMethod.GET)
    public String getAllCitys() {
        returnUtil = new ReturnUtil();
        try {
            List<CountryTable> countryTables =  countryDomain.getAllCountryByPid(1);

            return returnUtil.getSuccess(CountryJson.toJson(countryTables));
        } catch (Throwable throwable) {
            return dealException(throwable, returnUtil);
        }
    }
}
